package com.foreknow.elmboot.service.impl;

import com.foreknow.elmboot.mapper.BusinessMapper;
import com.foreknow.elmboot.po.Business;
import com.foreknow.elmboot.service.BusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Autowired Spring提供的注解
 * 作用：自动装配（依赖注入）控制反转(以前需要我们自己来创建dao层的对象，现在可以交给Spring来管理)
 * 我们在Service的实现类中需要注入一个Dao(mapper)层接口,接口的初始化的操作交给Spring进行处理
 *
 * @Service注解表示当前BusinessService层要交给Sping来管理，Spring提供了对事务的支持(try...catch可以省略)
 */
@Service
public class BusinessServiceImpl implements BusinessService {

    @Autowired
    private BusinessMapper businessMapper;

    @Override
    public List<Business> listBusinessByOrderTypeId(Integer orderTypeId) {
        return businessMapper.listBusinessByOrderTypeId(orderTypeId);
    }

    @Override
    public Business getBusinessById(Integer businessId) {
        return businessMapper.getBusinessById(businessId);
    }
}
